<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 定义一个类
        class Person {
            constructor(name, age) {
                this.name = name;
                this.age = age;
            }

            showname () {
                alert("my name is " + this.name);
            }

            showage () {
                alert("I am " + this.age);
            }
        }
        
        // 通过类来实例化一个对象
        let Andy = new Person("xuan", 55);
        // 调用对象上的方法
        Andy.showname();
        Andy.showage();

        // 定义类 继承Person
        class Student extends Person {
            constructor(name, age, school) {
                super(name, age);
                this.school = school;
            }

            showschool () {
                alert("my school is " + this.school);
            }
        }

        // 通过Student类实例化对象
        var Amy = new Student("xuan", 20, "xbmd");
        Amy.showschool();
    </script>
</head>
<body>
    
</body>
</html>